package com.xzy.demo.juc.locks;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

class MyCallable implements Callable<Integer> {
    @Override
    public Integer call() throws Exception {
        System.out.println("into call()");
        return 1024;
    }
}

/**
 * @author xzy
 * @date 2021/3/23 21:43
 * 说明：
 */
public class CallableDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Callable<Integer> callable = new MyCallable();

        FutureTask<Integer> futureTask = new FutureTask<>(callable);

        new Thread(futureTask, "A").start();

        System.out.println(futureTask.get());
    }
}
